package flyweight;

import java.util.HashMap;

/**
 * @Author: Doream
 * @Date: 2022/1/28 22:22
 */
public class BoxFactory {
    private HashMap<String,AbstratBox> map;
    private static BoxFactory boxFactory = new BoxFactory();

    // 在构造方法中进行初始化操作
    private BoxFactory() {
        map = new HashMap<>();
        map.put("I",new IBox());
        map.put("L",new IBox());
        map.put("O",new IBox());
    }

    public static BoxFactory getInstance(){
        return boxFactory;
    }

    // 根据名称获取图形对象
    public AbstratBox getShape(String name){
        return map.get(name);
    }
}
